import os
import time

from selenium import webdriver
from selenium.webdriver.common.by import By

# driver = webdriver.Chrome()
# url = "file:///" + os.path.abspath("../html1") + "/popup.html"
# driver.get(url)
# driver.maximize_window()
# button = driver.find_elements(By.TAG_NAME, 'button')
# button[0].click()
# alert = driver.switch_to.alert
# time.sleep(2)
# driver.quit()
# button[1].click()
# alert1 = driver.switch_to.alert
# time.sleep(2)
# alert.dismiss()
file = "file:///" + os.path.abspath("../html1") + "/popup.html"
driver = webdriver.Chrome()
driver.get(file)
btn = driver.find_elements(By.TAG_NAME, 'button')
btn[0].click()
#切换到alert
alert = driver.switch_to.alert
time.sleep(2)
alert.accept()
#comfirm
btn[1].click()
alter = driver.switch_to.alert
print(alter.text)
alter.dismiss()
btn[2].click()
alter = driver.switch_to.alert
print(alter.text)
alter.send_keys('大大大大')
alter.accept()
driver.quit()


